import axios from '@/utils/request'
export function noarticle(target) {
  return axios({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target
    }
  })
}
/**
 * 举报某文章
 * @param {*} target
 * @param {*} type
 * @returns
 */
export function reports(target, type) {
  return axios({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target,
      type
    }
  })
}

/**
 * 获取某文章
 */
export function articlecontent(id) {
  return axios({
    url: `/v1_0/articles/${id}`
  })
}

/**
 * 对某文章进行点赞
 */
export function likezan(target) {
  return axios({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 对某文章取消点赞
 * @param {} target
 * @returns
 */
export function qzan(target) {
  return axios({
    url: `/v1_0/article/likings/${target}`,
    method: 'DELETE'
  })
}

/**
 * 对某文章不喜欢
 */

export function like(target) {
  return axios({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 对某文章取消不喜欢
 */
export function qlike(target) {
  return axios({
    url: `/v1_0/article/dislikes/${target}`,
    method: 'DELETE'
  })
}

/**
 *获取文章的评论
 * @param {文章id} source
 * @returns
 */
export function getarticelcomment(source, offset) {
  return axios({
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source,
      offset,
      limit: 10
    }
  })
}

/**
 * 对某评论点赞
 * @param {评论的id} target
 * @returns
 */
export function addlikes(target) {
  return axios({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 取消点赞的评论
 * @param {取消点赞的评论id} target
 * @returns
 */
export function removelikes(target) {
  return axios({
    url: `/v1_0/comment/likings/${target}`,
    method: 'DELETE'
  })
}

/**
 * 对某文章评论
 * @param {文章id} target
 * @param {评论的内容} content
 * @returns
 */
export function addarticelcomment(target, content) {
  return axios({
    url: '/v1_0/comments',
    method: 'POST',
    data: {
      target,
      content
    }
  })
}

/**
 *获取文章的某评论的评论
 * @param {文章id} source
 * @returns
 */
export function getarticelcommentTocomment(source, offset) {
  return axios({
    url: '/v1_0/comments',
    params: {
      type: 'c',
      source,
      offset,
      limit: 10
    }
  })
}

/**
 * 对某文章评论进行回复
 * @param {文章id} target
 * @param {评论的内容} content
 * @returns
 */
export function addarticelcommentTocomment(artid, target, content) {
  return axios({
    url: '/v1_0/comments',
    method: 'POST',
    data: {
      art_id: artid,
      target,
      content
    }
  })
}
